//
//  TBCWeather.m
//  待定
//
//  Created by BoyaLee on 15/11/5.
//  Copyright © 2015年 BoyaLee. All rights reserved.
//

#import "TBCWeather.h"
#import "TBCPM2D5.h"
#import "TBCLocalWeather.h"

@implementation TBCWeather

+ (instancetype)shareTBCWeather {
    
    static TBCWeather *weather = nil;
    
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        
        weather = [[TBCWeather alloc] init];
        
    });
    
    return weather;
    
}



- (void)getWeather:(NSDictionary *)responseObject Key:(NSString *)key {
    
    NSDictionary *bigDic = responseObject;
    
    TBCWeather *weather = [[TBCWeather alloc] init];
    [weather setValuesForKeysWithDictionary:bigDic];
    weather.local = [bigDic objectForKey:key];
    
    weather.allWeatherArray = [NSMutableArray arrayWithCapacity:0];
    NSArray *array = [bigDic objectForKey:key];
    for (NSDictionary *dic in array) {
        TBCLocalWeather *localWeather = [[TBCLocalWeather alloc] init];
        [localWeather setValuesForKeysWithDictionary:dic];
        [weather.allWeatherArray addObject:localWeather];
    }
    
    NSDictionary *pm2d5 = [bigDic objectForKey:@"pm2d5"];
    weather.pm = [[TBCPM2D5 alloc] init];
    [weather.pm setValuesForKeysWithDictionary:pm2d5];
    
    [self.delegate sendWeather:weather];
    
}

- (void)setValue:(id)value forUndefinedKey:(NSString *)key {
    
}

@end
